<template>
    
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>分类参数</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片 -->
    <el-card>
      <el-alert
        title="注意：只允许为第三级分类设置相关参数！"
        type="warning"
        show-icon
        effect="dark"
      >
      </el-alert>
      <div class="cas">
        选择商品分类:
        <el-cascader
          v-model="value"
          :options="options"
          expand-trigger="hover"
          :props="cateProps"
          @change="handleChange"
        ></el-cascader>
      </div>
      <!-- 标签 -->
      <el-tabs type="border-card">
        <el-tab-pane label="动态参数">
          <el-button
            type="primary"
            size="mini"
            disabled
            style="margin-bottom: 20px"
            >添加参数</el-button
          >
          <!-- 表格 -->
          <el-table :data="tableData" style="width: 100%" border>
            <el-table-column type="expand">
              <template slot-scope="props"> </template>
            </el-table-column>
            <el-table-column label="#" type="index"> </el-table-column>
            <el-table-column label="参数名称" prop="name"> </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="props"> </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="静态属性">
          <el-button
            type="primary"
            size="mini"
            disabled
            style="margin-bottom: 20px"
            >添加属性</el-button
          >
          <!-- 表格 -->
          <el-table :data="tableData" style="width: 100%" border>
            <el-table-column type="expand">
              <template slot-scope="props"> </template>
            </el-table-column>
            <el-table-column label="#" type="index"> </el-table-column>
            <el-table-column label="属性名称" prop="name"> </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="props"> </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
import { categories } from "../../api/user";
export default {
  name: "",
  data() {
    return {
      options: [],
      value:[],
      value: [],
      tableData: [],
      cateProps: {
        label: "cat_name",
        value: "cat_id",
        children: "children",
      },
    };
  },
  created() {
    this.getList();
  },
  computed: {},
  methods: {
    async getList() {
      const { data: res } = await categories();
      console.log(res);
      this.options = res.data;
    },
    // 商品分类没有孙子就啥都没有
    handleChange() {
      if (this.value.length !== 3) {
        this.value = [];
        this.$message.warning('只允许三级分类设置参数！')
      }
    },
  },
};
</script>

<style scoped>
.cas {
  margin-top: 20px;
  margin-bottom: 20px;
}
</style>
